home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 65.zip / BS1 part 65 / Math Visin v2.1 disk 1.adf / Arexx.WB / Misc / AdjustColors < prev    next >
Text File  |  1992-02-12  |  2KB  |  93 lines

  1. /* AdjustColors   Do various transformations on MathVisions's Colors  19-Mar-90 
  2.  
  3. This is simply an example of how to use the Color control via ARexx.
  4.  
  5. ==========================================================================*/
  6.  
  7. ADDRESS "MathVision"
  8. OPTIONS RESULTS
  9. OPTIONS FAILAT 1
  10. SIGNAL ON ERROR
  11.  
  12. Get Depth
  13. NumColors = 2**RESULT
  14.  
  15. StopSign "F"
  16.  
  17. DO UNTIL Response = "X"
  18.   Response = Menu()
  19.   SELECT 
  20.     WHEN Response = "G" THEN
  21.     DO
  22.       CALL GetDMAColors
  23.         DO i = 0 to NumColors-1
  24.           Get Color i
  25.           PARSE VAR RESULT Red Green Blue
  26.           Average = Round((Red + Green + Blue) / 3)
  27.           Color i Average Average Average
  28.         END
  29.     END
  30.     WHEN Response = "R" THEN
  31.     DO
  32.       CALL GetDMAColors
  33.         DO i = 0 to NumColors-1
  34.           Color NumColors-1-i DMAColorR.i DMAColorG.i DMAColorB.i
  35.         END
  36.     END
  37.     WHEN Response = "S" THEN
  38.     DO
  39.       CALL GetDMAColors
  40.         DO i = 1 to NumColors-1
  41.           Before = i-1; IF Before<0 THEN Before = NumColors-1
  42.           After  = i+1; IF After>=NumColors THEN After = 0
  43.           Red   = Round((DMAColorR.Before + DMAColorR.i + DMAColorR.After) / 3)
  44.           Green = Round((DMAColorG.Before + DMAColorG.i + DMAColorG.After) / 3)
  45.           Blue  = Round((DMAColorB.Before + DMAColorB.i + DMAColorB.After) / 3)
  46.           Color i Red Green Blue
  47.         END
  48.     END
  49.     OTHERWISE;
  50.   END
  51.  
  52.   Get StopSign
  53.   IF (RESULT = "T") THEN EXIT
  54. END
  55.  
  56. EXIT
  57.  
  58. /*----------------------------------- Menu ------------------------------- */
  59. Menu:
  60. SAY d2c(12)
  61. SAY "G - Gray"
  62. SAY "S - Smooth ALL"
  63. SAY "R - Reverse"
  64. SAY "X - Exit"
  65. OPTIONS PROMPT "Enter Selection: "
  66. PULL RESPONSE
  67. RETURN Response
  68.  
  69. /*------------------------------ GetDMAColors ---------------------------- */
  70. GetDMAColors: PROCEDURE EXPOSE DMAColorR. DMAColorG. DMAColorB. NumColors
  71. DO i = 0 to NumColors-1
  72.   Get Color i
  73.   PARSE VAR RESULT DMAColorR.i DMAColorG.i DMAColorB.i
  74. END
  75. RETURN ""
  76.  
  77. /*------------------------------ SetDMAColors ---------------------------- */
  78. SetDMAColors: PROCEDURE EXPOSE DMAColorR. DMAColorG. DMAColorB. NumColors
  79. DO i = 0 to NumColors-1
  80.   Color i DMAColorR.i DMAColorG.i DMAColorB.i
  81. END
  82. RETURN ""
  83.  
  84. ROUND:  /* cheap trick to round argument to the nearest integer */
  85.   ARG ToRound
  86.   RETURN (ToRound+.5)%1
  87.  
  88. ERROR:         /* Error Diagnostic for return codes */
  89.   Get Diagnosis RC
  90.   SAY RESULT" on line "SIGL
  91.   do i=0 to 500; end
  92.   EXIT
  93.